/**
 * 列表数据为空时的占位组件
 */

import React from 'react';
import PropTypes from 'prop-types';
import ErrorPage from '@txdfe/at-error-page';
import './index.scss';

export default class ListEmpty extends React.Component {
  static propTypes = {
    content: PropTypes.string,
    description: PropTypes.string,
    btns: PropTypes.arrayOf(PropTypes.element),
    size: PropTypes.string,
    imgType: PropTypes.string,
  };

  static defaultProps = {
    content: '没有数据',
    description: '',
    btns: null,
    size: 'small',
    imgType: '',
  };

  render() {
    const { content, description, btns, size, imgType, className, ...others } = this.props;
    let image;
    switch (imgType) {
      case 'data':
        // 暂无数据
        image = 'https://img.alicdn.com/tfs/TB1EmeXhGL7gK0jSZFBXXXZZpXa-240-192.png';
        break;
      case 'comment':
        // 暂无评论
        image = 'https://img.alicdn.com/tfs/TB1xTechG67gK0jSZFHXXa9jVXa-240-192.png';
        break;
      case 'search':
        // 搜索无结果
        image = 'https://img.alicdn.com/tfs/TB1J2qihQT2gK0jSZFkXXcIQFXa-240-192.png';
        break;
      case 'access':
        // 无访问权限
        image = 'https://img.alicdn.com/tfs/TB1hJajhQT2gK0jSZPcXXcKkpXa-800-640.png';
        break;
      case 'filter':
        // 筛选无结果
        image = 'https://img.alicdn.com/tfs/TB15qCshUY1gK0jSZFMXXaWcVXa-240-192.png';
        break;
      case 'fail':
        image = 'https://img.alicdn.com/tfs/TB1g4yMloH1gK0jSZSyXXXtlpXa-700-504.png';
        break;
      case 'no-scan':
        image = 'https://img.alicdn.com/tfs/TB156JqnND1gK0jSZFsXXbldVXa-300-300.png';
        break;
      case 'tb-data':
        // 在tb中列表为空的展位图
        image = 'https://img.alicdn.com/tfs/TB1unn8orj1gK0jSZFuXXcrHpXa-144-144.png';
        break;
      case '500':
        image = 'https://img.alicdn.com/tfs/TB18dmMsQL0gK0jSZFAXXcA9pXa-800-640.png';
        break;
      case 'group-detail-data':
        // 子组无数据
        image = 'https://img.alicdn.com/tfs/TB1qV6MqXT7gK0jSZFpXXaTkpXa-700-504.png';
        break;
      default:
        image = '';
    }
    return (
      <ErrorPage
        size={size}
        image={image}
        title={content}
        desc={description}
        btns={btns}
        className={`code-list-empty ${className || ''}`}
        {...others}
      />
    );
  }
}
